package com.atguigu.yygh.task.task;

import com.atguigu.yygh.common.rabbit.RabbitService;
import com.atguigu.yygh.common.rabbit.consts.MqConst;
import com.atguigu.yygh.vo.msm.MsmVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @ClassName ScheduledTask
 * @Description 此类描述:
 * @Author dangchen
 * @DateTime 2022-10-23 11:28
 * @Version 1.0
 */
@Component
@EnableScheduling
public class ScheduledTask {
    @Autowired
    private RabbitService rabbitService;

    //从0秒开始,每5秒执行一次
    @Scheduled(cron = "0/5 * * * * ?")
    public void task1(){
        System.out.println(new Date().toLocaleString());
        rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK,MqConst.ROUTING_TASK_8,new MsmVo());
    }
}
